﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class VerifyNewUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
        {
            try
            {
                Guid userid = new Guid(Request.QueryString["ID"]);

                MembershipUser user = Membership.GetUser(userid);

                if (user != null)
                {
                    if (!user.IsApproved)
                    {
                        user.IsApproved = true;
                        Membership.UpdateUser(user);
                        Label1.Text = "Welcome, " + user.UserName + "<br/>Your registation has completed!";
                    }
                    else
                    {
                        Label1.Text = "Your account has already actived";
                    }
                }
                else
                {
                    Label1.Text = "Invalid ID";
                }
            }
            catch (Exception)
            {
                Label1.Text = "Invalid ID";
            }
        }
    }
}
